function [ x_new ] = Matrix_FourPointAvarage_boundary_V2( x1,x2,x3,x4,omega )
% Input:
% x(4,:,:)
% x = [i-1 i i+1 i+2] (the four adjacency matrices)
% omega is the tension parameter
% When x1==0 or x2==0 then we insert 0.
%-----------------------------------------------------------------
% Nir Sharon 29-05-12
%-----------------------------------------------------------------
N = size(x1,1);
Z = zeros(N);
I = eye(N);

if ((isequal(x1,Z))||((isequal(x2,Z))))
    x_new = Z;
else
    if (x3==Z)
        x3 = I;
    end
    if (x4==Z)
        x4 = I;
    end
    % calculation
    alpha = (1+14*omega)/(2+8*omega);
    x_new = GM2(GM2(x1,x2,alpha),GM2(x3,x4,(-.25)),-4*omega);
end

end
